Skip to content

Generate an exportable and ambient version of the TypeScript types#136

Merged
penalosa merged 2 commits intomainfrom
penalosa/comments-exportable
Nov 11, 2022
Merged

Generate an exportable and ambient version of the TypeScript types#136
penalosa merged 2 commits intomainfrom
penalosa/comments-exportable

Conversation

@penalosa
Copy link
Contributor

@penalosa penalosa commented Oct 28, 2022

This is blocked on merging #133

This follows on from @mrbbot's work, by parsing the outputted type definitions along with lib.webworker and lib.webworker.d.ts. It does two major things:

  • Attach doc comments from lib.webworker to the generated workers types, which gives much better documentation for standard types.
  • Generate two versions of the types:
    • api.ts which contains importable versions of the types. Importantly, they're only importable as types, not as values.
      The intention here is that it will be possible to type a worker in combination with an ambient lib.dom or lib.webworker declaration, as the ambient declaration will provide global (value) versions of Response and fetch etc... These will be slightly different to what's available in the workers runtime, of course, but not significantly so (see Workers/Standards diff for a look at how far off the workers runtime is from standards compliance).
    • api.d.ts which is the same as the current version of the types—purely ambient declarations.

@penalosa penalosa changed the base branch from main to bcoll/types-overrides October 28, 2022 10:01
@mrbbot mrbbot force-pushed the bcoll/types-overrides branch 2 times, most recently from 0c18f4e to 45fd54a Compare October 28, 2022 12:34
@penalosa penalosa force-pushed the penalosa/comments-exportable branch from 6ad28f0 to 5dfe33e Compare October 28, 2022 12:47
@penalosa penalosa changed the base branch from bcoll/types-overrides to main October 28, 2022 12:49
@penalosa penalosa changed the base branch from main to bcoll/types-overrides October 28, 2022 12:49
@penalosa penalosa force-pushed the penalosa/comments-exportable branch 3 times, most recently from 0c18f4e to be1df8e Compare October 28, 2022 13:10
@mrbbot mrbbot force-pushed the bcoll/types-overrides branch from 45fd54a to aad867d Compare October 31, 2022 18:00
@penalosa penalosa force-pushed the penalosa/comments-exportable branch from be1df8e to 30ed347 Compare November 2, 2022 13:39
@penalosa penalosa closed this Nov 2, 2022
@penalosa penalosa force-pushed the penalosa/comments-exportable branch from 30ed347 to aad867d Compare November 2, 2022 13:49
@penalosa penalosa reopened this Nov 2, 2022
@penalosa
Copy link
Contributor Author

penalosa commented Nov 2, 2022

@mrbbot This should be ready for review now:

  • Separate transformers for adding comments and making an exportable version of the types
  • Much less code

Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! This looks much better! Added some more comments. Sorry there are a lot, but they're mostly pretty small. I think we should be able to remove the ambient transformer too.

@penalosa penalosa requested a review from mrbbot November 2, 2022 20:38
@mrbbot mrbbot force-pushed the bcoll/types-overrides branch from aad867d to 2cc857a Compare November 3, 2022 11:37
Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more tiny things, but looks good to me! 🙂

@mrbbot mrbbot force-pushed the bcoll/types-overrides branch from 2cc857a to 5f1ddca Compare November 3, 2022 12:12
@penalosa penalosa requested a review from mrbbot November 3, 2022 13:48
@penalosa penalosa requested a review from mrbbot November 3, 2022 17:01
@mrbbot mrbbot force-pushed the bcoll/types-overrides branch 3 times, most recently from 46d8716 to 9229a5e Compare November 10, 2022 17:09
Base automatically changed from bcoll/types-overrides to main November 11, 2022 18:49
Copy link
Collaborator

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely needs a rebase but other LGTM

@penalosa penalosa force-pushed the penalosa/comments-exportable branch from 2ffc8b5 to f98a4f6 Compare November 11, 2022 19:13
@penalosa penalosa force-pushed the penalosa/comments-exportable branch from f98a4f6 to 29b7af0 Compare November 11, 2022 19:21
@penalosa penalosa merged commit 2e6b460 into main Nov 11, 2022
@penalosa penalosa deleted the penalosa/comments-exportable branch November 14, 2022 10:39
penalosa added a commit to penalosa/workerd that referenced this pull request Nov 14, 2022
* Generate an exportable and ambient version of the TypeScript types (cloudflare#136)

* Generate an exportable and ambient version of the TypeScript types

* Update compatibility-date.capnp

* Update compatibility-date.capnp

* Update package.json

* Update node-install.ts

* Add binary validation

* Penalosa/release to npm (#6)

* Update npm.yml

* Update node-install.ts

* Update package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add JSDocs documentation in types Generate exportable version of workers-types

3 participants